package com.ccys.cms.service.administrator.impl;


import com.ccys.cms.service.administrator.TblContentStyleWebService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.administrator.TblContentStyleDTO;
import com.ccys.db.entity.TblContentStyle;
import com.ccys.db.mapper.TblContentStyleMapper;
import com.ccys.db.page.PageUtils;
import com.ccys.db.rely.service.impl.BaseServiceImpl;
import com.ccys.db.vo.administrator.ContentStyleSelectVO;
import com.ccys.db.vo.administrator.TblContentStyleWebVO;

import com.ccys.db.vo.web.base.RoleSelectVO;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

import static com.ccys.common.vo.ResponseResult.success;


/**
 * tbl_content_style管理
 */
@Service
@Slf4j
public class TblContentStyleWebServiceImpl extends BaseServiceImpl<TblContentStyle> implements TblContentStyleWebService {

    @Autowired(required = false)
    private TblContentStyleMapper tblContentStyleMapper;

    @Override
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, TblContentStyleDTO dto) {
        PageUtils.startPage(request);
        List<TblContentStyleWebVO> list = this.tblContentStyleMapper.listObjectsCms(dto);
        PageInfo pageInfo = new PageInfo<>(list);
        return ResponseResult.success(pageInfo);
    }


    @Override
    public ResponseResult change(TblContentStyle entity) {
        if (StringUtils.isBlank(entity.getId())) {
            // 新增
            this.saveEntity(entity);
        } else {
            // 编辑
            this.updateEntityById(entity);
        }
        return ResponseResult.success();
    }

    @Override
    public ResponseResult delete(TblContentStyle dto) {
        TblContentStyle entity = new TblContentStyle();
        entity.setId(dto.getId());
        entity.setDelFlag(1);
        this.updateEntityById(entity);
        return ResponseResult.success();
    }

    @Override
    public ResponseResult selectList(TblContentStyleDTO dto) {
        List<ContentStyleSelectVO> list = this.tblContentStyleMapper.selectList(dto);
        return ResponseResult.success(list);
    }


}